import type { SortDirection,ColumnLayout } from "tabulator-tables";

/**
 * tabulator types
 */
export type {
  SortDirection,
  ColumnLayout,
}
export type TCompareSymbol =
  | 'equal'
  | 'notEqual'
  | 'greaterThan'
  | 'greaterThanOrEqual'
  | 'lessThan'
  | 'lessThanOrEqual'
  | 'isEmpty'
  | 'isNotEmpty'
  | 'includes'
  | 'notIncludes'
  | 'isBefore'
  | 'isAfter'

export type TLogicSymbol = 'AND' | 'OR'
export type ColumnType = 'text' | 'number' | 'date' | 'enum'

export type FilterCondition = {
  field: string
  title: string
  compareSymbol: TCompareSymbol
  value: Array<string | number | null>
  $type: ColumnType
  $fixed: boolean
}

export type FilterConfig = {
  logicSymbol: TLogicSymbol | null
  conditions: FilterCondition[]
}

export type ColumnConfig = {
  title: string
  field: string
  type: ColumnType
  enums?: (string | number)[]
}

export type GroupingConfig = {
  refCol: ColumnConfig
  sort: 'asc' | 'desc'
}

export type SortingConfig = GroupingConfig

export type DragSortingEvent<T> = {
  moved: {
    newIndex: number
    oldIndex: number
    element: T
  }
}


export type DataProcessConfig = {
  filter: FilterConfig
  grouping: { field: string, dir: SortDirection }[]
  sorter: { field: string, dir: SortDirection }[]
}
